
#ifndef __PHOTO_SCALE_AND_MOVE_WINDOW_H__
#define __PHOTO_SCALE_AND_MOVE_WINDOW_H__
#include <mzfc.h>
#include <mzfc_ui.h>
#include <mzfclib.h>
#include <ddraw.h>
class CPhotoScaleAndMoveWindow : public CMzWndEx
{
public:
	CPhotoScaleAndMoveWindow( const TCHAR *photoName, TCHAR *saveFileName );
	virtual ~CPhotoScaleAndMoveWindow();
	virtual void PaintWin(HDC hdc, RECT* prcUpdate /* = NULL */);
	void DrawTop( HDC hdc );
	void DrawBottom( HDC hdc );
	BOOL GetScalePhoto();
	void RedrawWindow();
protected:
	virtual BOOL OnInitDialog();
	virtual LRESULT MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam);
	virtual void OnLButtonDown(UINT fwKeys, int xPos, int yPos);
	virtual void OnLButtonUp(UINT fwKeys, int xPos, int yPos );
	virtual void OnMouseMove(UINT fwKeys, int xPos, int yPos );
	virtual void OnMzCommand(WPARAM wParam, LPARAM lParam);
	void OnLButtonDBClick( UINT fwKeys, int xPos, int yPos );

public:
	int m_winWidth;
	int m_winHeight;
	LPDIRECTDRAWSURFACE         m_pDDSOverlay; // The overlay primary.
	LPDIRECTDRAW                m_pDDraw;        // DirectDraw object
	LPDIRECTDRAWSURFACE         m_pDDSPrimary; // Primary Surface.
	BOOL m_bZoom;
	int m_vMove;
	CRect m_zoomDrawRect;
	int m_zoomOriginalX;
	int m_zoomOriginalY;
	HDC m_memZoomDC;
	HDC m_memDC;
	UiButton m_okBtn;
	UiButton m_cancelBtn;
private:
	void _SetEditPanel();
	void _SetTitlePanel();
	void _LoadImage(const TCHAR *fileName);
	void _AdjustImageSize( int *pNewWidth, int *pNewHeight, int dstWidth, int dstHeith, int origWidth, int origHeight );
	BOOL _InitDirectDraw();
	void _ReleaseAllObjects();
	void _InitImageThread();
public:
	void _GetAdjustOriginalMemDC();
	const TCHAR *m_photoName;
	IImagingFactory *m_pImagingFactory;
	ImagingHelper *m_pImageTop;
	ImagingHelper *m_pImageBottom;
	HINSTANCE m_hInst;
	CRect m_imageDrawRect;


	HBITMAP m_memZoomBmp;
	HGDIOBJ m_hZoomBmpOld; 
	//	BOOL m_bSetZoomDC;
	int m_zoomWidth;
	int m_zoomHeight;


	int m_rotateDegree;
	HDC m_memOriginalDC;
	HBITMAP m_memOriginalBmp;
	HGDIOBJ m_hOriginalBmpOld; 
	int m_imageWidth;
	int m_imageHeight;

	HBITMAP m_memBmp;
	HGDIOBJ m_hBmpOld; 
	POINT m_zoomDownPoint;

	int m_hMove;
	BOOL m_bMouseDown;
	POINT m_zoomMovePoint;
	POINT m_startPoint;
	POINT m_ptMouseMove;
	POINT m_ptMouseMovePrev;
	POINT m_ptMouseMovePrev2;
	TCHAR m_saveFileName[ MAX_PATH ];


	int m_leftMove;
	UINT m_callMessage;
	UINT m_smsMessage;
	BOOL m_bCanDecodeByHW;
	CRect m_adjustOriginalSrcRect;

	DWORD m_zoomImageThreadID;
	BOOL m_bCanProcessNextZoomMsg;
	HANDLE m_hZoomHandle;
	BOOL m_bMemCanDisplay;
	HDC m_memErrorDC;
	HBITMAP m_hBmpError;
	HGDIOBJ m_hOldError;


};

#endif


